<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="/res/third/bootstrap3/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="/res/common/js/jquery.1.9.1.min.js" type="text/javascript"></script>
<script src="/res/third/artDialog/jquery.artDialog.js" type="text/javascript"></script>
<script src="/res/third/validate/jquery.validate.js" type="text/javascript"></script>
<script type="text/javascript">
	function sosuo() {
		var lpath = location.pathname;
		$("#soform").attr("action", lpath + "?pageNo=" + 1);

		$("#soform").submit();
	}
</script>
</head>

<body>
	<div class="panel panel-info panel-content">
		<div class="panel-heading">
			<button style="float: right" type="button" onclick="addadvertise()" class="btn btn-info">
				<span class="glyphicon glyphicon-plus"></span>
				&nbsp;新增广告位
			</button>
			<form id="soform" method="post">
				<table>
					<tr>
						<td class="w80" style="padding-top: 5px">
							<label for="name" class="center-block">广告名称：</label>
						</td>
						<td class="w150 ">
							<input type="text" class="form-control" name="so_name" value="${so_name!}" id="so_name" placeholder="广告名称" data-options="">
						</td>
						<td style="padding-left: 10px">
							<div class="input-group">
								<span class="input-group-btn">
									<button class="btn btn-default" type="button" onclick="sosuo()">搜索</button>
								</span>
							</div>
						</td>
					</tr>
				</table>
			</form>
		</div>
		<table class="table table-hover table-bordered table-striped table-condensed">
			<thead>
				<tr>
					<th width="5">序号</th>
					<th width="15%">广告位名称</th>
					<th width="10%">启动状态</th>
					<th width="10%">广告数量</th>
					<th width="15%">广告类型</th>
					<th width="10%">显示条数</th>
					<th width="15%">广告位尺寸</th>
					<th width="20%">操作</th>
				</tr>
			</thead>
			[#list pagination.list as advertise ]
			<tr>
				<td align="center">${advertise_index + 1}</td>
				<td align="center">${advertise.adName!}</td>
				<td align="center">[#if advertise.state??][#if advertise.state==1]启用[#else]未启用[/#if][/#if]</td>
				<td align="center">${advertise.advcount!}</td>
				<td align="center">[#list dictionarys as dictionary][#if advertise.code??][#if advertise.adType?string==dictionary.code]${dictionary.name!}[/#if][/#if][/#list]</td>
				<td align="center">${advertise.adNum!}</td>
				<td align="center">${advertise.width}*${advertise.height}</td>
				<td align="center">
					<button type="button" class="btn btn-danger btn-xs delbtn" onclick="edit('${advertise.id}')">编辑</button>
					[#--<button type="button" class="btn btn-danger btn-xs delbtn" onclick="del('${advertise.id}')">删除</button>--]
					<button type="button" class="btn btn-danger btn-xs delbtn" onclick="detail('${advertise.id}', '${advertise.code!}')">管理</button>
				</td>
			</tr>
			[/#list]
		</table>

		<div class="panel-footer">[@fenye p = pagination form = 'infoForm' /]</div>
	</div>
</body>
</html>
<script type="text/javascript">
//跳转新增页面
	//跳转到新增页面
	function addadvertise() {
		top.addTempTab("/advertise/v_add.do");
	}
	//删除
	function del(id) {//弹出警告框判断是否删除
		if (confirm('是否确认删除')) {
			$.ajax({
				url : '/advertise/ajax_del.do',
				type : 'get',
				dataType : 'json',
				data : {
					id : id
				},
				beforeSend : function() {
					art.dialog.tips("删除中...");
				},
				success : function(data) {
					if (data.success) {
						location.reload();
					} else {
						error_msg(data.msg, function() {
							location.reload();
						});
					}
				}
			});
		}
	}

	//打开编辑窗口
	function edit(id) {
		top.addTempTab("/advertise/v_edit.do?so_id=" + id);
	}
	
	
	function detail(id, code) {
		if(code == 'INDEX_BANNER') {
			top.addTab('首页轮播', '/advertise/loadIndexAd.do');
		} else {
            top.addTempTab("/advertise/" + id + "/img_list.do");
        }
	}

</script>